from typing import List
class Solution:
    def longestConsecutive(self, nums: List[int]) -> int:
        res=0
        nums_set=set(nums)
        for num in nums_set:
            if num-1 not in nums_set:
                seq_len=1
                while num+1 in nums_set:
                    seq_len+=1
                    num+=1
                res=max(res,seq_len)
        return res


#最长连续序列